ANIMA.add("anima.component.base", function(A) {

A.namespace("anima.component.base");
 
A.anima.component.base.COMPONENT_BASE = "anima.component.base.ComponentBase";

A.anima.component.base.ComponentBase = function() {
   this.instanceId = null;
};
    
A.anima.component.base.ComponentBase.prototype = {
   queryInterface : function(componentInterface) {
      var provides = null;
      
      var descriptor = anima.getDescriptor(this.webid);
      
      while (descriptor != null && provides == null) {
         if (descriptor.provides && descriptor.provides != null &&
             descriptor.provides.indexOf(componentInterface) != -1)
            provides = this;
         else
            descriptor = (descriptor.superWebid && descriptor.superWebid != null)
               ? anima.getDescriptor(descriptor.superWebid) : null;
      }
      
      return provides;
   },
 
   /**
    * Returns the component Instance Id
    * 
    * @return the instanceId as String
    */
   getInstanceId : function() {
       return (this.instanceId) ? this.instanceId : null;
   },
 
   /**
    * instanceId to set (String)
    */
   setInstanceId : function(instanceId) {
       if (this.instanceId == null) {
           if (instanceId == null)
               this.instanceId = this.generateIntanceId();
           else
               this.instanceId = instanceId;
       }
   },
 
   /**
    * Generates an UUID to be used as instanceId.
    */
   generateIntanceId : function() {
       return A.anima.util.uuid();
   }
 
};
    
});